﻿<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
<%@include file="/static/common/header.jsp"%>
<%@include file="/static/common/easyui.jsp"%>
</head>
<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
<!-- 顶部-->
<div region="north" border="false" title="SpingSide Bootstrap V 0.0.1" style="BACKGROUND:#E6E6FA;height: 85px; padding: 1px; overflow: hidden;">
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td align="left" style="vertical-align:text-bottom" ><img src="${ctx}/static/images/logo.gif" > </td>
      <td align="right" nowrap><table>
          <tr>
            <td align="right" nowrap valign="top" height="50" style="font-size:12px"><span style="color: #CC33FF; ">用户名:</span><span style="color: #666633">(<shiro:principal/>) 
			<span style="color: #CC33FF; padding-left:10px;">  所属机构</span>:<span style="color: #666633">${ORG}</span> 
			</td>
          </tr>
          <td align="right" nowrap>
          <div style="position: absolute; right: 0px; bottom: 0px;">
          	<select id="locale" name="locale" onchange="changeLang(this.value)" style="width:100px;">
					<option value="zh_CN">
						中文
					</option>
					<option value="en">
						English
					</option>
			</select>
			
	          <a href="javascript:void(0);" class="easyui-menubutton" menu="#layout_north_kzmbMenu" iconCls="icon-help">控制面板</a>
	          <a href="javascript:void(0);" class="easyui-menubutton" iconCls="icon-back" onClick="javascript:logout();">注销</a>
          </div>
              <div id="layout_north_kzmbMenu" style="width: 100px; display: none;">
                <div onClick="javascript:modifyUser();"> 个人信息 </div>
                <div class="menu-sep"></div>
                <div onClick="javascript:modifyPwd();"> 修改密码 </div>
              </div></td>
          </tr>
        </table></td>
      <td align="right">&nbsp;&nbsp;&nbsp; </td>
    </tr>
  </table>
</div>
<!-- 左侧-->
<div region="west" split="false" title="导航菜单" style="width: 200px;">
   <!-- menu-->
      <div class="easyui-accordion" data-options="fit:true,border:false">
			<c:forEach items="${MenuList}" var="menu">
				<div title="${menu.name}" data-options="iconCls:'${menu.iconCls}'">
			 	<c:forEach items="${menu.subMenuList}" var="subMenu">
					<c:if test="${subMenu.available=='Y'}">
					<a id="btnadd" class="l-btn l-btn-plain" plain="true" style="width:190px;"
						onClick="newTab( '${subMenu.id}','${subMenu.name}' ,'${ctx}${subMenu.url}','${subMenu.iconCls}' )" href="javascript:void(0)">
					<span class="l-btn-left">
					<span class="l-btn-text ${subMenu.iconCls} l-btn-icon-left">
				      ${subMenu.name}
				    </span>
				    </span></a>
					</c:if>
				</c:forEach>
				</div>
			</c:forEach>
		</div>
      <!-- menu-->
</div>
<!-- -->
<div id="mainPanle" data-options="region:'center'" style="overflow: hidden;">
      <div id="mainTabContent" class="easyui-tabs" data-options="fit:true,border:false,plain:false"></div>
</div>
<!--  -->
<div region="south" border="false" style="height: 25px; overflow: hidden;">
  <div align="center" style="color: #CC99FF; padding-top: 2px"> &copy; <a title="SpingSide Bootstrap">SpingSide Bootstrap</a> </div>
</div>
<!-- 右键 -->
<div id="mm" class="easyui-menu" style="width:150px;">
        <div id="mm-tabclose">关闭</div>
        <div id="mm-tabcloseall">全部关闭</div>
        <div id="mm-tabcloseother">除此之外全部关闭</div>
        <div class="menu-sep"></div>
        <div id="mm-tabcloseright">当前页右侧全部关闭</div>
        <div id="mm-tabcloseleft">当前页左侧全部关闭</div>
        
</div>
<div id="innerFramWindow" class="easyui-window" data-options="closed:true,modal:true,collapsible:false,minimizable:false,maximizable:false,draggable:true,onBeforeClose:function(){}" style="overflow: hidden; border:none">
<iframe id="innerWinFram" scrolling="yes" frameborder="0"  src='' style="width:100%;height:100%; border:none; padding:10px;"></iframe>
</div>
<div id="MyPassWindow" modal="true" shadow="false" minimizable="false" cache="false" maximizable="false" collapsible="false" resizable="false" style="margin: 0px;padding: 0px;overflow: auto;"></div>

</body>
<script language="javascript">
 	$(document).ready(function(){
 		$("#locale").val('${locale}');
 		tabClose();
 		tabCloseEven();	
	})
function logout(){
 		if(confirm('确定退出系统')){
 			document.location.href='${ctx}/logout';
 		}
 	}
function changeLang(lang) {
		$.ajax({
			type : "post",
			url : '<c:url value="/Proxy/change.do"/>',
			data : "locale=" + lang,
			async : true,
			error : function(data, error) {
				alert("change lang error!");
			},
			success : function(data) {
				window.location.reload();
			}
		});
}	
function tabClose() {
	/* 双击关闭TAB选项卡 */
	$(".tabs-inner").dblclick(function() {
		var subtitle = $(this).children(".tabs-closable").text();
		$('#tabs').tabs('close', subtitle);
	})
	/* 为选项卡绑定右键 */
	$(".tabs-inner").bind('contextmenu', function(e) {
		$('#mm').menu('show', {
			left : e.pageX,
			top : e.pageY
		});

		var subtitle = $(this).children(".tabs-closable").text();

		$('#mm').data("currtab", subtitle);
		// $('#mainTabContent').tabs('select',subtitle);
		return false;
	});
}
// 绑定右键菜单事件
function tabCloseEven() {
	// 刷新
	$('#mm-tabupdate').click(function() {
		var currTab = $('#mainTabContent').tabs('getSelected');
		var url = $(currTab.panel('options').content).attr('src');
		$('#mainTabContent').tabs('update', {
			tab : currTab,
			options : {
				content : createFrame(url)
			}
		})
	})
	// 关闭当前
	$('#mm-tabclose').click(function() {
		var currtab_title = $('#mm').data("currtab");
		$('#mainTabContent').tabs('close', currtab_title);
	})
	// 全部关闭
	$('#mm-tabcloseall').click(function() {
		$('.tabs-inner span').each(function(i, n) {
			var t = $(n).text();
			$('#mainTabContent').tabs('close', t);
		});
	});
	// 关闭除当前之外的TAB
	$('#mm-tabcloseother').click(function() {
		$('#mm-tabcloseright').click();
		$('#mm-tabcloseleft').click();
	});
	// 关闭当前右侧的TAB
	$('#mm-tabcloseright').click(function() {
		var nextall = $('.tabs-selected').nextAll();
		if (nextall.length == 0) {
			return false;
		}
		nextall.each(function(i, n) {
			var t = $('a:eq(0) span', $(n)).text();
			$('#mainTabContent').tabs('close', t);
		});
		return false;
	});
	// 关闭当前左侧的TAB
	$('#mm-tabcloseleft').click(function() {
		var prevall = $('.tabs-selected').prevAll();
		if (prevall.length == 0) {
			return false;
		}
		prevall.each(function(i, n) {
			var t = $('a:eq(0) span', $(n)).text();
			$('#mainTabContent').tabs('close', t);
		});
		return false;
	});

	// 退出
	$("#mm-exit").click(function() {
		$('#mm').menu('hide');
	});
}

var title_now;
function newTab(opt,subtitle, url) {
		rowid="";
		icon="";
	if (!$('#mainTabContent').tabs('exists', subtitle)) { 
		if(opt.indexOf('panel') != -1){
			$('#mainTabContent').tabs('add', {
				title : subtitle,border:false,
				href : url,
				closable : true,
				icon : icon
			});	
		}else{
			$('#mainTabContent').tabs('add', {
				title : subtitle,border:false,
				//----------------------------------------------------------------
				//update-begin--Author:songsw  Date:20130325 for：数据源监控
				content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>',
				//update-end--Author:songsw  Date:20130325 for：数据源监控
				//----------------------------------------------------------------
				closable : true,
				icon : icon
			});			
		}

	} else {
		$('#mainTabContent').tabs('select', subtitle); 
	}

	tabClose();

}
function addTabPanel(_title , _url,_icon ){
		$('#mainTabContent').tabs('add',{
			title:_title,border:false,
			
			closable:true//,iconCls:_icon, href:_url
		});
		$('#mainTabContent').tabs('getTab',_title).panel('refresh', _url);
		tabClose();
}
$('#layout_east_calendar').calendar({
	fit : true,
	current : new Date(),
	border : false,
	onSelect : function(date) {
		$(this).calendar('moveTo', new Date());
	}
});
function showMsg() {
	showInfo("广而告之");
    setTimeout("showMsg()", 30000);
}
 
function init(){
	//var hhh=$(window).height();
	//var www=$(window).width();
}



$.extend($.fn.validatebox.defaults.rules, {
   
    equalTo: {
        validator: function (value, param) {
            return value == $(param[0]).val();
        },
        message: '两次输入的字符不一至'
    }
});
 
 
 String.prototype.endWith=function(s){
  if(s==null||s==""||this.length==0||s.length>this.length)
     return false;
  if(this.substring(this.length-s.length)==s)
     return true;
  else
     return false;
  return true;
 }
 String.prototype.startWith=function(s){
  if(s==null||s==""||this.length==0||s.length>this.length)
   return false;
  if(this.substr(0,s.length)==s)
     return true;
  else
     return false;
  return true;
 }
	var index=0,_currMenuId,flag=0;
	
	function newTab(_id,_title,_url,_icon){
		if(_url==''||_url=='/'){
			showInfoCenter("您点击的菜单 URL 为空！");
			return;
		}
		if ($('#mainTabContent').tabs('exists', _title)){  
			$('#mainTabContent').tabs('select', _title);  
		} else {
			var content = '<iframe id="_FrmID_'+_id+'" scrolling="auto" frameborder="0"  src="'+ _url +'" style="border:none; overflow:hidden; width:100%; height:100%"></iframe>';
			index++;
			$('#mainTabContent').tabs('add',{
				id:_id,
				title:_title,
				content:content,
				iconCls:_icon,
				closable:true,plain:true
			});
			tabClose();
		}
		
	}
	
	function closeAllTab(){	
		$('.tabs-inner span').each(function(i,n){
			var t = $(n).text();
			$('#mainTabContent').tabs('close',t);
		});	 
	}
	
	function resizeContent(_heigth,_width){
		  $("#showRegion").css("height",_heigth);
		$("#mainLayout").css("height",_heigth);
		//$("#_FrmID_").css("height",_heigth);
		$("#mainLayout").layout("resize");
		//$('#mainTabContent').resize(); 
	}
	
	function quit(){
		window.parent.document.location.href="login.html";
	}
	function modifyPwd(){
		openWin2('MODIFY PASSWORD','${ctx}/Mng/user/passWin',500,300);
	}
	function modifyUser(){
		 showInfoCenter("Hi：<shiro:principal/>");
		 //openWin2("用户信息","login.html" ,500,600 ) ; 
	}
</script>
</html>


